package com.ruoyi.controller.jpjs.proprogress;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.service.jpjs.PublicService;
import com.ruoyi.service.jpjs.proprogress.ProProgressService;
import com.ruoyi.util.BaseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

/**
 * @author zeo
 * 在建项目进度、人员统计表
 */

@Controller
@RequestMapping("/proProgress")
public class ProProgressController extends BaseController {

    private String prefix = "jpjs/proprogress";

    @Autowired
    PublicService publicService;

    @Autowired
    ProProgressService proProgressService;

    @GetMapping()
    public String proProgress(ModelMap mmap) {
        mmap.put("userComp", publicService.findUserCompAndJszb());
        return prefix + "/proProgress";
    }

    @RequestMapping("/list")
    @ResponseBody
    public TableDataInfo list(@RequestParam Map map) {
        List<Map<String,Object>> list = proProgressService.list(map);
        return getDataTable(list);
    }

    @RequestMapping("/findPersonNum")
    @ResponseBody
    public BaseResult findPersonNum(Double total_area){
        return proProgressService.findPersonNumByTotalArea(total_area);
    }

    @GetMapping("/add")
    public String add(ModelMap mmap) {
        mmap.put("userComp", publicService.findUserCompAndJszb());
        return prefix + "/add";
    }

    @RequestMapping("/add")
    @ResponseBody
    public AjaxResult add(@RequestParam Map map) {
        return toAjax(proProgressService.add(map));
    }

    @GetMapping("/edit/{id}")
    public String edit(ModelMap mmap,@PathVariable("id") String id) {
        mmap.put("data",proProgressService.findDataById(id));
        mmap.put("userComp", publicService.findUserCompAndJszb());
        return prefix + "/edit";
    }

    @RequestMapping("/edit")
    @ResponseBody
    public AjaxResult edit(@RequestParam Map map) {
        return toAjax(proProgressService.edit(map));
    }

}


